// CSE 142 Winter 2008, Marty Stepp // // This program reads a file of temperatures and displays // the change in temperature between neighboring days. // It is an example of an "inchworm" fencepost solution. import java.io.*; // for File import java.util.*; // for Scanner public class Temperatures { public static void main(String[] args) throws FileNotFoundException { Scanner input = new Scanner(new File("temperatures.txt")); int temp1 = input.nextInt(); int temp2; while (input.hasNextInt()) { temp2 = temp1; temp1 = input.nextInt(); System.out.println("Temp changed by " + (temp2 - temp1) + " deg F"); } } }